package twoD.IsoPfem.EmbededCrackModels;

import inf.jlinalg.ArrayVector;
import inf.jlinalg.IVector;
import inf.jlinalg.Vector2D;

public class CrackingState {
	private Vector2D[] displacement_;
	private IVector[] crackOpeningParameters_;
	private double[] complianceParameter_;

	public CrackingState(int numberOfNode, int numberOfElement) {
		displacement_ = new Vector2D[numberOfNode];
		crackOpeningParameters_ = new IVector[numberOfElement];
		complianceParameter_ = new double[numberOfElement];
	}

	public void setDisplacement(IVector U) {
		for (int i = 0; i < displacement_.length; i++) {
			displacement_[i] = new Vector2D(U.get(2 * i), U.get(2 * i + 1));
		}
	}

	public void setDisplacement(double u) {
		for (int i = 0; i < displacement_.length; i++) {
			displacement_[i] = new Vector2D(0, 0);
		}
	}

	public Vector2D getDisplacement(int i) {
		return displacement_[i];
	}

	public void setGamma(double[] d) {
		complianceParameter_ = d.clone();
	}

	public void setGamma(double d) {
		for (int i = 0; i < complianceParameter_.length; i++)
			complianceParameter_[i] = d;
	}

	public double getGamma(int i) {
		return complianceParameter_[i];
	}

	public double[] getGamma() {
		return complianceParameter_;
	}

	public void setZeroCrack() {
		for (int i = 0; i < crackOpeningParameters_.length; i++)
			crackOpeningParameters_[i] = new ArrayVector(2);
	}

	public void setCrack(IVector[] e) {
		crackOpeningParameters_ = e;
	}

	public IVector[] getCrackOpeningParameters() {
		return crackOpeningParameters_;
	}

	public IVector getCrackOpeningParameters(int i) {
		return crackOpeningParameters_[i];
	}
}
